<?
/**
 * VoiceOne Settings/LAN
 *
 * Frontend to provide access to the lan setup system in voiceone.
 * @package voiceone
 * @subpackage  settings_lan
 */
  include ("../../admin/config/cfg.php");
  global $cwlang, $cwLanguage;
  
  //================ PAGE LOGIC ================

  if (count($_POST)>0) {
    foreach($_POST as $k=>$v) {
      if (is_int($k)) {
        $entry[]=array("id" => $k, "value" => "$v");
        $entryNet[]=$v;
      }
    }

    $ret=$asterisk->putOption($entry);
    $ret=$asterisk->updateNetwork($entryNet);
    if ($ret>0) $alert="<div class=\"AlertGood\">".$cwlang["lan"]["alertGood"]."</div>";
    else $alert="<div class=\"AlertBad\">".$cwlang["lan"]["alertBad"]."</div>";
  }
  
  $html=getOption(OPTION_LAN);
  
  //================ MAIN CONTENTS ================
  ob_start();
  ?>
  
  <div class="SectionHeader">
    <?=$alert?>
    <h1><?=$cwlang["lan"]["title"]?></h1>
  </div>

  <div id="basic_form">
    <form action="<?=$PHP_SELF?>" method="post">
      <table>
        <tr>
          <td valign="top">
            <p class="blockintro"><?=$cwlang["lan"]["titleDesc"]?></p>
            <div class="block">
              <p><strong><?=$cwlang["lan"]["warning"]?></strong></p><br />
              <table>
                <?=$html?>
              </table>

            </div>
          </td>
        </tr>
      </table>

      <div class="action">
        <input type="image" src="<?=$relBasePath?>/public/img/<?=$cwLanguage?>/b-save.gif" alt="Save" />
      </div>
    </form>
  </div>      
  <?
  $contents=ob_get_contents();
  ob_end_clean();

  //================ SIDEBAR ================
  ob_start(); 
  ?>
        <div class="Sidebar">
          <h1><?=$cwlang["lan"]["sidebarTitle"]?></h1>
            <?=$cwlang["lan"]["sidebarDesc"]?>
        </div>
  <?  
  $sidebar=ob_get_contents();
  ob_end_clean();

  //================ SETTINGS ================

  $smarty->assign("section", "lan");
  $smarty->assign("subsection", "");
  $smarty->assign("templateType", "TwoColLeft");  //OneCol, TwoColLeft, TwoColRight
  $smarty->assign("contents", $contents);
  $smarty->assign("sidebar", $sidebar);
  $smarty->display('settings.tpl');
?>

